package com.nothing.thread.lock;

import java.util.Collection;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.locks.Condition;
import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReentrantLock;

/**
 * @author haining
 */
public class TestCondition {
    Lock lock = new ReentrantLock();
    Condition condition = lock.newCondition();

    public void conditionWait() throws InterruptedException {
        lock.lock();
        try {
            condition.await();
        } finally {
            lock.unlock();
        }
    }

    public void conditionSignal() {
        lock.lock();
        try {
            condition.signal();
        } finally {
            lock.unlock();
        }
    }

    public static void main(String[] args) throws InterruptedException {

        new Thread(){
            @Override
            public void run() {
                super.run();
            }
        }.start();
        TestCondition testCondition = new TestCondition();
        testCondition.conditionWait();
//        testCondition.conditionSignal();
        System.out.println("*****");
        Thread.sleep(1);
    }
}
